<!DOCTYPE HTML>
<html>
	<head> 
	<title>游资动向</title>
	<link href="css/text.css" rel="stylesheet" type="text/css" />
	<meta charset="utf-8" />
	<style>
		.fixedBox{
			border: 0px solid #555555;				
			white-space: nowrap;	
		}
		.fixedBox::-webkit-scrollbar {
			width: 0px;     
			height: 0px;				
		}
		.highlight {
            	background-color: #045df7;  /* 被搜索 标签颜色 */
       		}
		table{
			width:300px; 
			border-collapse:collapse; 
			text-align:center;
		}
		td,th{border:1px solid #696969}		
		
		#tag{
			margin:-5px 10px 5px 0px;
			border: 1px solid #FFFF88;
			padding: 3px;
			display: inline-block;
			color: #F9F9F9;
		}
		#tag1{
			margin-left:10px;
			border: 1px solid #FF0000;
			padding: 3px;
			display: inline-block;
			color: #FFFF00;
		}
		#tag2{	
			margin-left:10px;
			border: 1px solid #00FF00;
			padding: 3px;
			display: inline-block;
			color: #FFFF00;
		}
		#tag3{	
			margin-left:10px;
			border: 1px solid #FFBF80;
			padding: 3px;
			display: inline-block;
			color: #FFFFB9;
		}
		#tag4{	
			margin-left:10px;
			border: 1px solid #FF0000;
			padding: 3px;
			display: inline-block;
			color: #FF80FF;
		}		
		#tag5{	
			margin-left:10px;
			border: 1px solid #00FF00;
			padding: 3px;
			display: inline-block;
			color: #6FFFB7;
		}				
	</style>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script>
	</head>
	<body>
		<div id="title"></div>
		<div id="content" class="fixedBox"></div>	
		<script>
			var bkcolor = $("body").css("backgroundColor");
			var dt = "";
			var tt = "";			
			var k = 0;
			var tdx = 1; 
			var g = 1; //龙虎榜买卖显示格式（1：对齐；0：紧凑）
			
			window.onload = function() {	 
				

				if(navigator.userAgent.indexOf("TdxW") == -1){ //识别是否为通达信
					tdx = 0;
				}
				var day = new Date();				
				mymonth = day.getMonth()+1;
				myday = day.getDate();
				if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
				if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
				tt = day.getFullYear() + "-" + mymonth + "-" + myday;
				//dt = tt;			
				changeStyle();
				start();



			} 
			
			function changeStyle() {				
				var div = document.getElementById("title");				
				div.style.left= "0px"; 				
				div.style.width= "98%";	
				div.style.height= "20px";	
				
				var div = document.getElementById("content");				
				div.style.top= "35px"; 
				div.style.left= "10px"; 				
				div.style.width= "98%";	
				div.style.height= "100%";
				div.style.fontSize= "14px";		
			}
			
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function getLocalTime(nS) {			          
				return new Date(parseInt(nS*1000)).Format("hh:mm:ss")
			}

			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};		
			
			function NumberTransform(num) { 
				var result = parseFloat(num);
				if (isNaN(result)) {                    
				   return false;  
				}  				
				if(Math.abs(result) > 100000000){
					result = result / 100000000;
					result = result.toFixed(2) + "亿";
				}else if(Math.abs(result) > 10000){
					result = result/10000;
					result = result.toFixed(0) + "万";
				}
				return result;  
			}
			
			
			function cDayFunc(dp){ 
				var date = dp.cal.getNewDateStr();
				BookingRmk(date);//调用其它函数并带上参数  
			}
			
			function BookingRmk(date){         
				tt = date;
				var date1 = new Date(tt);
				var date2 = new Date(dt);
				k = 0;
				if(date1.getTime() < date2.getTime()){			
					k = 1;
					tradeday();
				}else{
					tt = dt
				}
				//getSource(fs)
				setTimeout(function(){getSource(fs)}, 100);  //延时执行;						
			}
			
			function prev(){  //前一天
				pn = -1;
				var day = new Date(tt);	
				day.setTime(day.getTime() - 24*60*60*1000);	
				tt = day.Format("yyyy-MM-dd");
				BookingRmk(tt);
			}
			
			function next(){  //后一天 				
				pn = 1;
				var day = new Date(tt);	
				day.setTime(day.getTime() + 24*60*60*1000);	
				tt = day.Format("yyyy-MM-dd");
				BookingRmk(tt);			
			}
			
			var pn = -1;
			function tradeday() {  //判断最后交易日
				var day = new Date(tt);							
				for (i = 1; i < 100; i++){	//节假日																										
					if(i > 1){
						day.setTime(day.getTime() + pn*24*60*60*1000);							
					}	
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					if(tt == dt){	
						k = 0;
						getSource(fs);
						break;
					}
					var url = "https://applhb.longhuvip.com/w1/api/index.php?c=Index&a=YouZiDongXiangByList&apiv=w34&Time=" + tt;
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,						
						success: function(data) {							
							//alert(JSON.stringify(data))		
							res = data.DongXiang;
						}
					});
					if(res != "[]"){						
						break;
					}
				}
			}				
			
			function start() {
				var div = document.getElementById('title');
				var p1 = "<a href='javascript:void(0)' id='px1' onclick='getSource(1)'>" + "游资动向" + "</a>";				
				var p2 = "<a href='javascript:void(0)' id='px2' onclick='getSource(2)'>" + "机构" + "</a>";	
				var p3 = "<a href='javascript:void(0)' id='px3' onclick='getSource(3)'>" + "股票" + "</a>";
				var p4 = "<a href='javascript:void(0)' id='px4' onclick='getSource(4)'>" + "营业部" + "</a>";	
				div.innerHTML = '<font size="4">游资动向</font><font size="2">（ ' + p1 + p2 + p3 + p4 + '）</font><input style="width:100px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';						
				var back = '<a href="javascript:prev();"  style="padding-left:10px;;font-size:16px;color:#fff;">←</a>';					
				var forward = '<a href="javascript:next();"  style="padding-left:10px;font-size:16px;color:#fff;">→</a>';

				var inport ='<input type="text" id="searchInput" placeholder="输入搜索内容">';
     			var button ='<button id="searchButton" style="position: absolute;top: 12px; left: 620px;width:60px;height:22px;" onclick="searchClick()"">搜索</button>';

				//div.innerHTML += back + forward +inport+ button + '<br>';
				div.innerHTML += '&nbsp;&nbsp;'+inport+  button + '<br>';
				
				getSource(fs);
			}

			
			function searchClick(){
				const searchInput = document.getElementById('searchInput');
				const searchButton = document.getElementById('searchButton');
				const contentDiv = document.querySelectorAll('.seearchcontent');

				const searchTerm = searchInput.value.trim().toLowerCase();

				const highlightedElements = document.querySelectorAll('.highlight');
				highlightedElements.forEach(element => {
					element.classList.remove('highlight');
				});

				if (searchTerm === '') {
					return;
				}

				//这个方式 也行
				// const paragraphs_td = contentDiv.querySelectorAll('td');
				// let found = false;

				// paragraphs_td.forEach(paragraph => {
				// 	const paragraphsA = paragraph.querySelectorAll('a');
				// 	paragraphsA.forEach(paragraphA=>{

				// 		const text = paragraphA.textContent.toLowerCase();
				// 		if (text.includes(searchTerm)) {
				// 			paragraph.classList.add('highlight');
				// 			found = true;
				// 			return;
				// 		} 
				// 	}
				// 	); 
					
				// });

				 // 再查找所有的 <a> 标签  用这个方式 省资源
				let found = false; 
				contentDiv.forEach(element=> { 
					const links = element.querySelectorAll('a');
					if(links.length == 0){
						const text = element.textContent.toLowerCase();
						if (text.includes(searchTerm)) {
								element.classList.add('highlight');
								found = true;  
							}
					}else{ 
						links.forEach(link => {
						const text = link.textContent.toLowerCase();
							if (text.includes(searchTerm)) {
								//缓存一个消息 方便搜索
								//localStorage.setItem('message', searchTerm);

								const parentTd = link.closest('td');
								if (parentTd) {
									parentTd.classList.add('highlight');
									found = true; 
								}
							}
						});
					}
					
				}); 

				if (!found) {
					alert('未找到相关内容。');
				} 
			}
			

			function load(name) {
				var xhr = new XMLHttpRequest()							
				okStatus = document.location.protocol === "file:" ? 0 : 200;				
				xhr.open('GET', name, false);
				xhr.overrideMimeType("text/html;charset=gb2312");//默认为utf-8				
				xhr.send(null);
				return xhr.status === okStatus ? xhr.responseText : null;
			}

			
			var fs = 1;			
			function getSource(p) {
				fs = p;				
				var alist = document.getElementById("title").getElementsByTagName("a");					
				for(var i = 0; i < alist.length; i++){				
					alist[i].style.color = "#F9F9F9"; //给所有a标签赋原色
				}
				var aObj = document.getElementById('px' + p);				
				aObj.style.color = "#FFA07A";		
				
				var div = document.getElementById('content');
				div.innerHTML = "";				
				if(p == 1){
					var url1 = "https://applhb.longhuvip.com/w1/api/index.php?c=Index&a=YouZiDongXiangByList&apiv=w34";
					var url2 = "https://applhb.longhuvip.com/w1/api/index.php?c=Index&a=YouZiDongXiangByList&apiv=w34&Time=" + tt;
					
					var url = url1;
					if(k == 1){
						url = url2;
					}
					
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));							
							res = data.DongXiang;
							if(k == 0){	
								tt = data.Time;								
								dt = tt;
							}							
						}
					});
					//document.write(JSON.stringify(res));
					
					var newDiv1 = document.createElement("div");
					newDiv1.id = "游资动向";					
					newDiv1.className = "fixedBox seearchcontent";
					newDiv1.style.position= "relative"; 
					newDiv1.style.float= "left";
					newDiv1.style.left= "0px"; 
					newDiv1.style.width= "320px";		//游资动向左侧宽度
					//newDiv1.style.border= "2px solid #FFFF00";
					div.appendChild(newDiv1);
					
					
					var newDiv2 = document.createElement("div");
					newDiv2.id = "yzgp";
					newDiv2.className = "fixedBox seearchcontent";
					newDiv2.style.position= "relative"; 
					newDiv2.style.float= "left"; 
					//newDiv2.style.top= "40px";
					newDiv2.style.left= "0px"; 
					newDiv2.style.width= "450px";	   //游资动向右侧宽度
					div.appendChild(newDiv2);
					
					var newDiv3 = document.createElement("div");
					newDiv3.id = "lhb";
					newDiv3.className = "fixedBox seearchcontent";
					newDiv3.style.position= "relative"; 
					newDiv3.style.float= "left"; 
					//newDiv3.style.top= "40px";
					newDiv3.style.left= "0px"; 
					newDiv3.style.width= "550px";	   //龙虎榜宽度
					div.appendChild(newDiv3);
					
					if(res.length > 0){						
						for (var i = 0; i < res.length; i++){
							var arr = [];
							var aa= res[i].List;
							for (var j = 0; j < aa.length; j++){								
								arr.push({"代码":aa[j].ID,"名称":aa[j].Name,"涨幅":aa[j].IncreaseAmount,"净额":aa[j].Money})
							}
							function up(a,b){
								return b.净额 - a.净额											
							}
							arr.sort(up);
							
							var mc = res[i].ShortName;
							if(mc=="深南东路"){
								mc = "深南东路【总舵主】";
							}

							if(mc=="北京光华路"){
								mc = "北京光华路【毛老板】";
							}

							var id = res[i].ID;
							var name = "<a class='seearchcontent' style='color:#FFFF88;font-size:16px' href='javascript:void(0)' id='id" + mc + "' onclick='yzgp(\"" + mc + "\"," + id + ")'>" + mc + "</a>";
							newDiv1.innerHTML += "<p style='margin:0px 0px 5px 5px;'>" + name + "</p>";
							var newDiv = document.createElement("div");
							newDiv.id = mc; 
							newDiv1.appendChild(newDiv);
							
							ids = "游资动向";
							tables(arr,mc);								
							
							if(i == 0){
								yzgp(mc,id);
							}
						}
						for(var i = 0; i < res.length; i++){
							var table = document.getElementsByTagName("table")[i];							
							makeSortable(table,i,ids);
							hover();
						}			
					}				
				}else if(p == 3){
					var url1 = "https://applhb.longhuvip.com/w1/api/index.php?st=500&a=GetStockList&c=LongHuBang&Index=0&apiv=w34&Type=2&Time=";
					var url2 = "https://applhb.longhuvip.com/w1/api/index.php?st=500&a=GetStockList&apiv=w34&Type=2&Index=0&c=LongHuBang&Time=" + tt;
					
					var url = url1;
					if(k == 1){
						url = url2;
					}
					
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));							
							res = data;												
						}
					});
					//document.write(JSON.stringify(res));
					
					var newDiv = document.createElement("div");
					newDiv.id = "股票";
					newDiv.className = "fixedBox seearchcontent";
					newDiv.style.position= "relative"; 
					newDiv.style.float= "left"; 
					newDiv.style.left= "0px"; 
					newDiv.style.width= "700px";	   //左侧宽度							
					div.appendChild(newDiv);
					
					var newDiv1 = document.createElement("div");
					newDiv1.id = "lhb";
					newDiv1.className = "fixedBox seearchcontent";
					newDiv1.style.position= "relative"; 
					newDiv1.style.float= "left"; 
					newDiv1.style.left= "0px"; 
					newDiv1.style.width= "550px";	   //龙虎榜宽度
					div.appendChild(newDiv1);
					
					var arr = [];
					if(res.list.length > 0){
						var BIcon = res.BIcon;
						var SIcon = res.SIcon;
						var TIcon = res.TIcon;
						var lb = res.lb;
						for (var i = 0; i < res.list.length; i++){
							var aa = res.list[i];
							var code = aa.ID;
							//alert(JSON.stringify(BIcon[code]))"undefined"
							var byyb = "";
							var arrb = BIcon[code];
							if(arrb != undefined){
								for (var j = 0; j < arrb.length; j++){
									//byyb += "<span id='tag1'>" + arrb[j] +"</span>";
									byyb += arrb[j] + ",";
								}
							}
							byyb = byyb.substr(0,byyb.length - 1);
							
							var syyb = "";
							var arrs = SIcon[code];
							if(arrs != undefined){
								for (var j = 0; j < arrs.length; j++){
									//syyb += "<span id='tag2'>" + arrs[j] +"</span>";
									syyb += arrs[j] + ",";
								}
							}
							syyb = syyb.substr(0,syyb.length - 1);
							
							var tyyb = "";
							var arrt = TIcon[code];
							if(arrt != undefined){
								for (var j = 0; j < arrt.length; j++){
									//tyyb += "<span id='tag3'>" + arrt[j] +"T</span>";
									tyyb += arrt[j] + ",";
								}
							}
							tyyb = tyyb.substr(0,tyyb.length - 1);
							
							var lbs = "";
							var bb = lb[code];
							if(bb != undefined){								
								//lbs += "<span style='margin-left:10px;color:#FF80FF;'>" + bb +"连板</span>";
								lbs = bb;
							}
							var name = aa.Name;
							var zf = aa.IncreaseAmount;
							var je = aa.BuyIn;												
							<!-- newDiv.innerHTML += "<p style='margin-bottom:-5px;'><a style='color:#F9F9F9;' href='http://www.treeid/code_" + code  -->
							<!-- + "' onclick='lhb(\"" + code + "\",\"" + tt + "\");changeCss1(this);'>" + name + "&nbsp;&nbsp;涨幅：" + zf + "&nbsp;&nbsp;净额："  -->
							<!-- + NumberTransform(je) + lbs + byyb + syyb + tyyb + "</a></p>"; -->
							
							arr.push({"代码":code,"名称":name,"涨幅":zf,"净额":je,"天":lbs,"买入游资":byyb,"卖出游资":syyb,"T游资":tyyb})
						}
						function up(a,b){
							return b.净额 - a.净额											
						}
						arr.sort(up);
						//document.write(JSON.stringify(arr));
						ids = "股票";
						tables(arr,"股票",ids);

						var table = newDiv.getElementsByTagName("table")[0];							
						makeSortable(table,0,ids);
						hover();
					}				
				}else if(p == 2){
					var url1 = "https://applhb.longhuvip.com/w1/api/index.php?a=GetAgencyListV2&st=500&apiv=w34&c=LongHuBang&Index=0"; 								
					var url2 = "https://applhb.longhuvip.com/w1/api/index.php?a=GetAgencyListV2&st=500&apiv=w34&c=LongHuBang&Index=0&Time=" + tt;				
					var url = url1;
					if(k == 1){
					  url = url2;
					}
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));														
							res = data.List;							
						}
					});	
					//document.write(JSON.stringify(res.List));
					var arr = [];
					for (var i = 0; i < res.length; i++){
						var aa = res[i];
						arr.push({"代码":aa.ID,"名称":aa.Name,"涨幅":aa.IncreaseAmount,"净额":aa.BuyIn,"机构数":aa.JoinNum,"流通市值":NumberTransform(aa.CircPrice),"换手率":aa.TurnoverRatio})
					}
					function up(a,b){
						return b.净额 - a.净额											
					}
					arr.sort(up);		
					var newDiv = document.createElement("div");
					newDiv.id = "机构";
					newDiv.className = "fixedBox seearchcontent";
					newDiv.style.position= "relative"; 
					newDiv.style.float= "left"; 
					newDiv.style.left= "0px"; 
					newDiv.style.width= "500px";	   //左侧宽度							
					div.appendChild(newDiv);
					
					var newDiv1 = document.createElement("div");
					newDiv1.id = "lhb";
					newDiv1.className = "fixedBox seearchcontent";
					newDiv1.style.position= "relative"; 
					newDiv1.style.float= "left"; 
					newDiv1.style.left= "0px"; 
					newDiv1.style.width= "550px";	   //龙虎榜宽度
					div.appendChild(newDiv1);
					
					ids = "机构";
					tables(arr,"机构");	
					
					var table = document.getElementsByTagName("table")[0];							
					makeSortable(table,0,ids);
					hover();
				}else if(p == 4){
					var url1 = "https://applhb.longhuvip.com/w1/api/index.php?a=GetBusinessList&st=100&c=LongHuBang&Index=0&apiv=w34&Type=0"; 								
					var url2 = "https://applhb.longhuvip.com/w1/api/index.php?a=GetBusinessList&st=100&c=LongHuBang&Index=0&apiv=w34&Type=0&Time=" + tt;				
					var url = url1; 


					if(k == 1){
					  url = url2;
					}
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));														
							res = data.list;
										
						}
					});	
					//document.write(JSON.stringify(res));
					var arr0 = [];
					for (var i = 0; i < res.length; i++){
						var aa = res[i];
						var buy = aa.Buy;
						var sell = aa.Sell;
						var je = buy - sell;
						arr0.push({"代码":aa.ID,"名称":aa.Name,"净额":je,"关联数":aa.JoinNum})
					}
					function up(a,b){
						return b.净额 - a.净额											
					} 

					arr0.sort(up);  

					var 统计席位 = "";	//需要监控的席位
					try {
							var text = load("席位跟踪.txt");   
							统计席位=text;
					} catch (error) {
							alert("席位跟踪.txt????");
					}  

					var arr=[]
					if(统计席位 != ""){
						const lines = 统计席位.split(/\r?\n/); 

						const arr2map = new Map();
						lines.forEach(item => {
							const [key, value] = item.split('#'); // 按#分割为键值对数组
							arr2map.set(key, value);
						});

						
						// 1. 提取a的键顺序
						const aKeysOrder = Array.from(arr2map.keys()); // ["a", "f", "hf", "p", "w", "q"]

						// 2. 创建键值映射（键名 -> 排序权重）
						const keyWeightMap = {};
							aKeysOrder.forEach((key, index) => {
							keyWeightMap[key] = index+1;
						});

						// 3. 对b数组按a的键顺序排序
						const sortedB = [...arr0].sort((itemA, itemB) => {
							const weightA = keyWeightMap[itemA.名称] || Number.MAX_SAFE_INTEGER; // 未匹配的排最后
							const weightB = keyWeightMap[itemB.名称] || Number.MAX_SAFE_INTEGER;
							return weightA - weightB;
						});

						sortedB.forEach(item => {
							const originalName = item.名称;
							const aValue = arr2map.get(originalName) || ""; // 获取a中对应键的值，默认空字符串 
							item.名称 = `${originalName}【${aValue}】`; // 拼接新名称
							if(aValue=="") item.名称 = `${originalName}`;
						});

						arr=sortedB;
 
					}else{
						arr=arr0;
					}


					var newDiv = document.createElement("div");
					newDiv.id = "营业部";					
					newDiv.className = "fixedBox seearchcontent";
					newDiv.style.position= "relative"; 
					newDiv.style.float= "left";
					//newDiv.style.top= "40px";
					newDiv.style.left= "0px"; 
					newDiv.style.width= "400px";	//营业部左侧宽度
					div.appendChild(newDiv);
					
					var newDiv1 = document.createElement("div");
					newDiv1.id = "yybgp";
					newDiv1.className = "fixedBox seearchcontent";
					newDiv1.style.position= "relative"; 
					newDiv1.style.float= "left"; 
					//newDiv1.style.top= "40px";
					newDiv1.style.left= "0px"; 
					newDiv1.style.width= "380px";	 //营业部右侧宽度
					//newDiv1.style.border= "2px solid #fff";
					div.appendChild(newDiv1);
					
					var newDiv2 = document.createElement("div");
					newDiv2.id = "lhb";
					newDiv2.className = "fixedBox seearchcontent";
					newDiv2.style.position= "relative"; 
					newDiv2.style.float= "left"; 
					newDiv2.style.left= "0px"; 
					newDiv2.style.width= "600px";	   //龙虎榜宽度
					div.appendChild(newDiv2);
					
					ids = "营业部";
					tables(arr,"营业部",ids);

					var table = newDiv.getElementsByTagName("table")[0];							
					makeSortable(table,0,ids);
					hover();
					
					$("#营业部 a")[1].click();
				}
				document.getElementById("PriceDate").value = tt;
				div.scrollTop = 0; //回到顶部	
			}
			
			var ids = "";
			function yzgp(mc,id) {
				var div = document.getElementById('yzgp');
				div.innerHTML = "<p style='color:#FFFF88;font-size:16px;'>" + mc + "</p>";
				
				var money = 500;  //万
				var url1 = "https://applhb.longhuvip.com/w1/api/index.php?apiv=w31&c=BusinessGroup&a=GroupInfo&GID=" + id;
				var res1 = [];
				$.ajax({
					type: "get",
					url: url1,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));																				
						div.innerHTML += "<p style='margin-top:-10px;color:#F9F9F9;white-space: normal;'>" + data.Info + "</p>";
						var yyb = "";
						for (var i = 0; i < data.BusinessList.length; i++){
							var aa = data.BusinessList[i];
							yyb += "<span id='tag'>" + aa.Name + "</span>";
						}
						div.innerHTML += "<p style='white-space: normal;'>" + yyb + "</p>";
					}
				});	
				
				var url = "https://applhb.longhuvip.com/w1/api/index.php?apiv=w31&c=BusinessGroup&a=GroupLog&GID=" + id + "&st=1000&Index=0&Money=" + money * 10000 + "&Order=2&Day=3";
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));														
						res = data.list;								
					}
				});	
					
				var arr = [];
				for (var i = 0; i < res.length; i++){
					var aa = res[i];
					var buy = aa.Buy;
					var sell = aa.Sell;
					var je = buy - sell;
					var type = "买入";					
					if(aa.Type == "2"){
						type = "卖出";
					}
					arr.push({"代码":aa.StockID,"名称":aa.Name,"日期":aa.Time,"涨幅":aa.IncreaseAmount,"净额":je,"类别":type})
				}
				
				ids = "yzgp";
				tables(arr,"yzgp");
				
				var table = div.getElementsByTagName("table")[0];							
				makeSortable(table,0,ids);
				hover();
				
				div.scrollTop = 0; //回到顶部
			}
			
			function yybgp(mc,id) {			
				var div = document.getElementById('yybgp');
				div.innerHTML = "<p style='color:#FFFF88;font-size:14px;'>" + mc + "</p>";
				var money = 500;  //万
				var url = "https://applhb.longhuvip.com/w1/api/index.php?apiv=w31&c=Business&BusinessID=" + id + "&Time=12&st=1000&a=GetNewDoStockLog&Index=0&Day=3&Money=" + money * 10000 + "&Order=2"; 								
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));														
						res = data.list;								
					}
				});	
					
				var arr = [];
				for (var i = 0; i < res.length; i++){
					var aa = res[i];
					var buy = aa.Buy;
					var sell = aa.Sell;
					var je = buy - sell;
					var type = "买入";
					if(aa.Type == "2"){
						type = "卖出";
					}
					arr.push({"代码":aa.StockID,"名称":aa.Name,"日期":aa.Time,"涨幅":aa.IncreaseAmount,"净额":je,"类别":type})
				}
				
				ids = "yybgp";
				tables(arr,"yybgp");
				
				var table = div.getElementsByTagName("table")[0];							
				makeSortable(table,0,ids);
				hover();
				
				div.scrollTop = 0; //回到顶部
			}
			
			function lhb(code,tt) {	
				var div = document.getElementById('lhb');
				div.innerHTML = "";
				var newDiv = document.createElement("div");
				newDiv.id = "龙虎榜";											
				newDiv.style.width= "130%";
				div.appendChild(newDiv);
				
				var name = "";
				var ytdbusin = "";
				var url = "https://applhb.longhuvip.com/w1/api/index.php?apiv=w31&c=Stock&a=GetNewOneStockInfo&Type=0&Time=" + tt + "&StockID=" + code; 								
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));	
						name = data.Name;
						ytdbusin = data.ytdbusin;
						newDiv.innerHTML = "<p style='color:#FFFF88;font-size:14px;'>" + name + "<span style='margin-left:10px;'>" + tt + "</span></p>";
						newDiv.innerHTML += "<p style='margin:-10px 0px 10px 0px;color:#FFF;'>净买入：" + NumberTransform(data.BuyIn) + "<span style='margin-left:20px;'>关联营业部数：" + data.ToBusinessCount + "</span></p>";
						
						res = data.List;						
					}
				});	
				
				//document.write(JSON.stringify(res));	
				var count = 1;
				var w = 0; //营业部名称宽度
				for (var j = 0; j < res.length; j++){					
					var ly = res[j].UpReason;
					for (var i = 0; i < ly.length; i++){
						if(j == 0){
							if(i == 0){
								newDiv.innerHTML += "<p style='float:left;margin:-10px 0px 0px 0px;color:#00FFFF;width:98%;'>上榜理由：" + ly[i] + "</p>";
							}else{
								newDiv.innerHTML += "<p style='float:left;margin:0px 0px -5px 0px;color:#00FFFF;width:98%;'>上榜理由：" + ly[i] + "</p>";
							}
						}else{
							newDiv.innerHTML += "<p style='float:left;margin:20px 0px -10px 0px;color:#00FFFF;width:98%;'>上榜理由：" + ly[i] + "</p>";
						}
					}
					
					newDiv.innerHTML += "<p style='float:left;margin-bottom:-10px;color:#FF8040;font-size:16px;'>买入营业部：" + "<span style='color:#FFFF00;font-size:14px;'>买入总计" + NumberTransform(res[j].BuyTotal) + "元</span></p>";					
					var newDiv1 = document.createElement("div");
					newDiv1.id = "买入营业部";
					newDiv1.className = "fixedBox seearchcontent";
					newDiv1.style.position= "relative"; 
					newDiv1.style.float= "left"; 					
					newDiv1.style.left= "0px"; 
					newDiv1.style.width= "98%";
					//newDiv1.style.background= "#460023";    
					newDiv1.style.border= "2px solid #C0C0C0";
					newDiv.appendChild(newDiv1);
										
					for (var i = 0; i < res[j].BuyList.length; i++){
						var aa = res[j].BuyList[i];
						var id = aa.ID;
						var name = aa.Name;
						//alert(name)
						var px = aa.PX;
						var buy = aa.Buy;
						var sell = aa.Sell;
						var je = buy - sell;
						
						var yzp = "";
						var youZiIcon = aa.YouZiIcon;
						if(youZiIcon == 1){
							yzp = "一线游资";
						}else if(youZiIcon == 2){
							yzp = "顶级游资";					
						}else if(youZiIcon == 3){
							yzp = "知名游资";					
						}
						if(yzp != ""){
							yzp = "<span id='tag1'>" + yzp + "</span>";
						}
						
						var yzmc = "";
						var groupicon = aa.GroupIcon[0];
						if(groupicon != undefined){
							yzmc = "<span id='tag1'>" + groupicon + "</span>";
						}
						
						var gl = "";
						var associcon = aa.AssocIcon;
						if(associcon == 1){
							gl = "<span id='tag1'>关联</span>";
						}
						
						var zb = "";
						var zs = "";
						if(ytdbusin != ""){
							var ystb = ytdbusin.buy;
							if(ystb != undefined){
								var aa = ystb[id];
								if(aa != undefined){
									zb = "<span id='tag4'>昨买" + aa + "</span>";
								}
							}
							
							var ysts = ytdbusin.sell;
							if(ysts != undefined){
								var aa = ysts[id];
								if(aa != undefined){
									zs = "<span id='tag5'>昨卖" + aa + "</span>";
								}
							}
						}
												
						//买卖显示格式
						if(g == 0){
							newDiv1.innerHTML += "<p>" + px + "、" + name + "<span style='margin-left:10px;color:#FF80FF;'>买：" + 
							NumberTransform(buy) + "</span><span style='margin-left:5px;color:#00FF80;'>卖：" + NumberTransform(sell) + 
							"</span><span style='margin-left:5px;color:#fff;'>净额："+ NumberTransform(je) + "</span></p>";
						}else if(g == 1){
							newDiv1.innerHTML += "<p><span id=" + count + "a>" + px + "、" + name + "</span><span id=" + count + "b style='color:#FF80FF;'>买：" + 
							NumberTransform(buy) + "</span><span id=" + count + "c style='color:#00FF80;'>卖：" + NumberTransform(sell) + 
							"</span><span id=" + count + "d style='color:#fff;'>净额："+ NumberTransform(je) + "</span></p>";
							
							//计算字符长度
							var diva = document.getElementById(count + 'a');
							var dw = diva.offsetWidth;
							if(dw > w){
								w = dw;
							}
						}
						
						if(gl + yzp + yzmc + zb + zs != ""){
							newDiv1.innerHTML += "<p style='margin:-15px 0px 0px 15px;'>" + gl + yzp + yzmc + zb + zs + "</p>";
						}
						count++;
					}
					
					newDiv.innerHTML += "<p style='float:left;margin-bottom:-10px;color:#00FF80;font-size:16px;'>卖出营业部：" + "<span style='color:#FFFF00;font-size:14px;'>卖出总计" + NumberTransform(res[j].SellTotal) + "元</span></p>";			
					var newDiv2 = document.createElement("div");
					newDiv2.id = "卖出营业部";
					newDiv2.className = "fixedBox seearchcontent";
					newDiv2.style.position= "relative"; 
					newDiv2.style.float= "left"; 					
					newDiv2.style.left= "0px"; 
					newDiv2.style.width= "98%";
					//newDiv2.style.background= "#002800";
					newDiv2.style.border= "2px solid #C0C0C0";
					newDiv.appendChild(newDiv2);
					for (var i = 0; i < res[j].SellList.length; i++){
						var aa = res[j].SellList[i];
						var id = aa.ID;
						var name = aa.Name;
						var px = aa.PX;
						var buy = aa.Buy;
						var sell = aa.Sell;
						var je = buy - sell;
						var yzp = "";
						var youZiIcon = aa.YouZiIcon;
						if(youZiIcon == 1){
							yzp = "一线游资";
						}else if(youZiIcon == 2){
							yzp = "顶级游资";					
						}else if(youZiIcon == 3){
							yzp = "知名游资";					
						}
						if(yzp != ""){
							yzp = "<span id='tag1'>" + yzp + "</span>";
						}
						
						var yzmc = "";
						var groupicon = aa.GroupIcon[0];
						if(groupicon != undefined){
							yzmc = "<span id='tag1'>" + groupicon + "</span>";
						}
						
						var gl = "";
						var associcon = aa.AssocIcon;
						if(associcon == 1){
							gl = "<span id='tag1'>关联</span>";
						}
						
						var zb = "";
						var zs = "";
						if(ytdbusin != ""){
							var ystb = ytdbusin.buy;
							if(ystb != undefined){
								var aa = ystb[id];
								if(aa != undefined){
									zb = "<span id='tag4'>昨买" + aa + "</span>";
								}
							}
							var ysts = ytdbusin.sell;
							if(ysts != undefined){
								var aa = ysts[id];
								if(aa != undefined){
									zs = "<span id='tag5'>昨卖" + aa + "</span>";
								}
							}
						}
						
						//买卖显示格式
						if(g == 0){
							newDiv2.innerHTML += "<p>" + px + "、" + name + "<span style='margin-left:10px;color:#FF80FF;'>买：" + 
							NumberTransform(buy) + "</span><span style='margin-left:5px;color:#00FF80;'>卖：" + NumberTransform(sell) + 
							"</span><span style='margin-left:5px;color:#fff;'>净额："+ NumberTransform(je) + "</span></p>";
						}else if(g == 1){
							newDiv2.innerHTML += "<p><span id=" + count + "a>" + px + "、" + name + "</span><span id=" + count + "b style='color:#FF80FF;'>买：" + 
							NumberTransform(buy) + "</span><span id=" + count + "c style='color:#00FF80;'>卖：" + NumberTransform(sell) + 
							"</span><span id=" + count + "d style='color:#fff;'>净额："+ NumberTransform(je) + "</span></p>";
							
							//计算字符长度
							var diva = document.getElementById(count + 'a');
							var dw = diva.offsetWidth;
							if(dw > w){
								w = dw;
							}
						}
						
						if(gl + yzp + yzmc + zb + zs != ""){
							newDiv2.innerHTML += "<p style='margin:-15px 0px 0px 15px;'>" + gl + yzp + yzmc + zb + zs + "</p>";
						}
						count++;
					}					
				}
				
				//设定买卖数据起始位置 
				if(g == 1){
					var n = 30;
					for (var i = 1; i < count; i++){
						var div1 = document.getElementById(i + 'b');
						div1.style.position= "absolute"; 
						div1.style.left= w + n + "px";
						
						var div2 = document.getElementById(i + 'c');
						div2.style.position= "absolute"; 
						div2.style.left= w + n + 80 + "px";
						
						var div3 = document.getElementById(i + 'd');
						div3.style.position= "absolute"; 
						div3.style.left= w + n + 160 + "px";
					}
					newDiv.style.width= w + n + 260 + "px";
				}
				
				div.scrollTop = 0; //回到顶部
			}
			
			function changeCss1(obj){				
				var alist = document.getElementById("content").getElementsByTagName("a");					
				for(var i = 0; i < alist.length; i++){				
					if(alist[i].id != "xq" && alist[i].id.indexOf("px") == -1){
						alist[i].style.color = "#F9F9F9"; //给所有a标签赋原色
					}
				}
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			var gl = "净额";  //高亮
			function tables(data,id) {
				if(data.length > 0){	
					var json = data;
					
					//创建table					
					var table=document.createElement("table");										
					var thead=document.createElement("thead");
					table.appendChild(thead);					
					var tr=document.createElement("tr");
					thead.appendChild(tr);					
					
					var m = 0;
					var n = 0;
					var q = 0;
					var rq = tt;					
					for(var key in json[0]){  //表头
						key = key.replace('Sto','代码').replace('StoN','名称').replace('Money','净额');
						var th=document.createElement("th");						
						th.innerHTML=key;						
						tr.appendChild(th);
						if(gl == key.replace("%","")){
							n = m;
							if(ids != "yzgp" && ids != "yybgp"){
								th.style.color = "#FFFF80";	
							}
						}
						if(key == "日期"){
							q = m;
						}
						m++;
					}

					var tbody=document.createElement("tbody");					
					table.appendChild(tbody);
					
					//遍历json
					for(var i = 0; i < json.length; i++){					
						var tr=document.createElement("tr");						
						var p = 1;
						var dm = "";
						var mc = "";
						for(var key in json[i]){ //行元素遍历						
							var td=document.createElement("td");							
							
							var rc = json[i][key];
							if(p == 1){  //代码列
								dm = rc;
								tr.id = i + "#" + id + "#" + dm;
							}else if(p == 2){
								mc = rc;
							}else if(p == n + 1){
								rc = NumberTransform(rc);
							}
							
							if(p > 1 && p == q + 1){
								rq = rc;
							}
							
							var href = "http://www.treeid/code_" + dm;							
							if(tdx == 0){
								href = "javascript:void(0);";	
							}
							td.innerHTML = "<a href=" + href + " id='" + p + "' onclick='lhb(\"" + dm + "\",\"日期\");changeCss(\"" + tr.id + "\",\"" + ids + "\")'>" + rc + "</a>";
							//td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='lhb(\"" + dm + "\",\"日期\");changeCss(\"" + tr.id + "\",\"" + ids + "\")'>" + rc + "</a>";
							
							if(id == "营业部"){
								td.innerHTML = "<a href='javascript:void(0);' id='" + p + "' onclick='yybgp(\"" + mc + "\"," + dm + ");changeCss(\"" + tr.id + "\",\"" + ids + "\")'>" + rc + "</a>";								
							} 

							if(key=="净额"){
								_width = "55px";
								td.style="max-width: "+_width+";text-overflow:ellipsis;white-space:nowrap;";
							}  
							
							if(p == n + 1 && ids != "yzgp" && ids != "yybgp"){														
								var value = parseFloat(JSON.stringify(rc).replace('万','').replace('亿','').replace(/"/,''));							
								if(value >= 0){
									td.getElementsByTagName("a")[0].style.color = "#FF6633";
								}else{
									td.getElementsByTagName("a")[0].style.color = "#00FF00";
								}							
							}
							
							tr.appendChild(td);													
							p++;
						}
						tr.innerHTML = tr.innerHTML.replace(/日期/g,rq);
						tbody.appendChild(tr);																
					}
					
					var div1 = document.getElementById(id);												
					div1.appendChild(table);
					table.id = "table" + id;	
					if(fs > 1){
						changeTable(table,"0")
					}					
				}						
			}
			
			//隐藏某列				
            function changeTable(table,ss) {	
				var trs = table.rows;
				ss = ss + '#';
				var aa = ss.split('#');
				for (var j = 0; j < aa.length; j++) {
					if(aa[j] != ""){
						for (var i = 0, len = trs.length; i < len; i++) {					
							var p = aa[j];
							var cell = trs[i].cells[p]; 
							cell.style.display = 'none';
						}
					}
				}					
			}
			
			function makeSortable(table,p,id) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){						
							showCol(n,p,id)
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt == "名称" || headtxt == "日期" || headtxt == "类别" || headtxt.indexOf("游资") > -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt == "天"){
									if(val1 == ""){
										val1 = 0;
									}else{
										val1 = parseInt(val1);
									}
									
									if(val2 == ""){
										val2 = 0;
									}else{
										val2 = parseInt(val2);
									}
								}else{
									
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol(iCol,p,id){
				var div = document.getElementById(id);
				var oTable = div.getElementsByTagName('table')[p];
				
				//表头
				var th = oTable.getElementsByTagName("th");						
				for (var i=0;i < th.length; i++){	    //列遍历
					th[i].style.color = "#E5E5E5";      //还原										
					th[iCol].style.color = "#FFFF80";	//选中				
				}
				
				var tr = oTable.getElementsByTagName("tr");	
				for (var i=1;i < tr.length; i++){	//行遍历
					var otagsA = tr[i].getElementsByTagName("a");
					for (var j=0;j < otagsA.length; j++){	//列遍历						
						otagsA[j].style.color = "#E5E5E5";	//还原	
					}
					var value = otagsA[iCol].innerText.replace(/(万)|(亿)|(%)/g,'');
					value = value.replace("买入","1").replace("卖出","-1");
					if(!isNaN(parseFloat(value)) && isFinite(value)){  //判断列是否为数字
						if(parseFloat(value) >= 0){
							otagsA[iCol].style.color = "#FF6633";     //正负颜色
						}else{
							otagsA[iCol].style.color = "#00FF00";
						}
					}else{
						otagsA[iCol].style.color = "#FF6633";
					}					
				}					
			}	
			
			var trid = "";
			function changeCss(hid,id){
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor;			
				}
				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			function hover(){ 
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头														
							this.style.background = bkcolor;
							if(this.id == trid){									
								this.style.background="#483D8B";
							}							
						}
					}					
				}
			}
			
		</script>		
	</body>
</html>